using System.Xml.Serialization;

namespace my_newconsole.Report;

/// <summary>
/// 报告指标（精确到每个单元格）
/// </summary>
public class IndexItem
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="name">指标名称</param>
    /// <param name="englishName">英文名称</param>
    /// <param name="row">所在行</param>
    /// <param name="column">所在列</param>
    /// <param name="sort">排序码</param>
    /// <param name="defaultValue">默认值</param>
    public IndexItem(
        string name,
        int row,
        int column,
        int sort, 
        string englishName,
        string defaultValue = null)
    {
        this.Name = name;
        this.EnglishName = englishName;
        this.Row = row;
        this.Column = column;
        this.Sort = sort;
        this.DefaultValue = defaultValue;
    }

    public IndexItem() {}

    /// <summary>
    /// 指标名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 英文名
    /// </summary>
    public string EnglishName { get; set; }

    /// <summary>
    /// 编码
    /// </summary>
    public string Code { get; set; }

    /// <summary>
    /// 排序码
    /// </summary>
    public int Sort { get; set; }

    /// <summary>
    /// 行号（以0开始）
    /// </summary>
    public int Row { get; set; }

    /// <summary>
    /// 列号（以0开始）
    /// </summary>
    public int Column { get; set; }

    /// <summary>
    /// 默认值
    /// </summary>
    public string DefaultValue { get; set; }

    /// <summary>
    /// 数据转化
    /// </summary>
    public string Convert(string val)
    {
        if (val == "正常")
            return "";
        if (val == "√" && !string.IsNullOrWhiteSpace(DefaultValue))
            return DefaultValue;
        return val;
    }
}

[XmlRoot("parmDetails")]
public class ParmDetails
{
    [XmlElement("parmDetail")]
    public List<ParmDetail> ParmDetail { get; set; }
}

[XmlRoot("parmDetail")]
public class ParmDetail
{
    /// <summary>
    /// 参数代码
    /// </summary>
    [XmlElement("parmItemNo")]
    public string ParmItemNo { get; set; }

    /// <summary>
    /// 参数英文名称
    /// </summary>
    [XmlElement("parmEngName")]
    public string ParmEngName { get; set; }

    /// <summary>
    /// 参数中文名称
    /// </summary>
    [XmlElement("parmChnName")]
    public string ParmChnName { get; set; }

    /// <summary>
    /// 参数值
    /// </summary>
    [XmlElement("parmValue")]
    public string ParmValue { get; set; }

    /// <summary>
    /// 排序号
    /// </summary>
    [XmlElement("parmSortNo")]
    public string ParmSortNo { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [XmlElement("remark")]
    public string Remark { get; set; }
}
